#ifndef MODEL_H
#define MODEL_H

#include <QList>
#include <QSqlTableModel>
#include <QSqlDatabase>
#include <QString>

#include <Task.h>

static const char MODEL_TABEL_NAME [] = "main_table";

class Model : public QSqlTableModel
{
    Q_OBJECT
public:
    explicit Model(QObject *parent = 0, QSqlDatabase db = QSqlDatabase());
    ~Model();
   /*
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
   */
    Qt::ItemFlags flags ( const QModelIndex & index ) const;
    const QList<Task>& tasks() const;
    void add(Task task);
    int state(int row) const;
    int priority(int row) const;
    QUrl url(int row) const;
    QString path(int row) const;

private:
    void createTableIfNeeded();

signals:
    
public slots:

private:
    QList<Task> data_;
};

#endif // MODEL_H
